let app = require('./app');
let path = require('path');

// 中间件
let koaStatic = require('koa-static');
app.use(koaStatic(path.join(__dirname, './public')));
// let KoaRouter = require('koa-router');
let requestTimeMiddleware = require('./middleware/time_log.js');
let bodyParser = require('koa-bodyparser');

let router = require('./routes');

app.use(bodyParser());

// 中间件
app.use(router.routes()).use(router.allowedMethods());

app.use(requestTimeMiddleware);

const port = 3000;

app.listen(port, () => {
  console.log(`服务已启动 端口号是${port}`);
});
